apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: werfsources.deckhouse.io
  labels:
    heritage: deckhouse
    module: delivery
spec:
  group: deckhouse.io
  scope: Cluster
  names:
    plural: werfsources
    singular: werfsource
    kind: WerfSource
  preserveUnknownFields: false
  versions:
    - name: v1alpha1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          description: |
            Delivery source configuration for Argo CD and werf bundle.

            Used to create a registry configuration for Argo CD Image Updater and optionally to create an OCI Helm repository in Argo CD to use with werf bundles.
          required:
            - spec
          properties:
            spec:
              type: object
              required:
                - imageRepo
              properties:
                imageRepo:
                  type: string
                  description: Image repository.
                  x-example: registry.example.com/my-project
                  pattern: ^(?:[a-z0-9]+(?:[.-][a-z0-9]+)*)(/(?:[a-z0-9._-]+))*$
                apiURL:
                  type: string
                  pattern: ^https?://(?:[a-z0-9]+(?:[.-][a-z0-9]+)*)$
                  description: |
                    URL of the registry API.

                    Automatically derived from the [imageRepo](#werfsource-v1alpha1-spec-imagerepo) parameter if not specified.
                    E.g. if `imageRepo=cr.example.com/myproject`, then `apiURL` is derived as
                    `https://cr.example.com/`.
                pullSecretName:
                  type: string
                  pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
                  description: |
                    Name of the secret of type `kubernetes.io/dockerconfigjson` with credentials for the registry.

                    The secret must be in namespace `d8-delivery`.
                argocdRepoEnabled:
                  type: boolean
                  default: true
                  description: |
                    Whether to create Argo CD repository for this source.

                    If `true`, then the OCI-enabled repository
                    will be created in Argo CD with name `name`. Turn it off if you want to create the repository manually,
                    e.g. based on git or Helm Chart Museum.
                argocdRepo:
                  type: object
                  default: {}
                  description: |
                    Argo CD repository configuration.

                    If `argocdRepoEnabled` is `true`, then the repository
                    will be created in Argo CD with the same name as the resource.
                  properties:
                    project:
                      type: string
                      default: "default"
                      minLength: 1
                      description: |
                        Name of the Argo CD project to which the repository will be added.

                        If not specified, then the repository will be added to the default project.
